<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>订单管理 - 后台</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 20px; background-color: #f4f4f4; }
        .container { max-width: 1200px; margin: 20px auto; padding: 30px; border: 1px solid #ddd; border-radius: 8px; background-color: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
        h1 { color: #333; text-align: center; margin-bottom: 20px; }
        table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
        th, td { border: 1px solid #ddd; padding: 10px; text-align: left; }
        th { background-color: #f2f2f2; }
        .action-links a { margin-right: 10px; color: #007bff; text-decoration: none; }
        .action-links a:hover { text-decoration: underline; }
        .back-link { display: block; margin-top: 20px; text-align: center; }
        .back-link a { color: #007bff; text-decoration: none; }
        .back-link a:hover { text-decoration: underline; }
    </style>
</head>
<body>
    <div class="container">
        <h1>订单管理</h1>
        <table>
            <thead>
                <tr>
                    <th>订单ID</th>
                    <th>订单号</th>
                    <th>用户</th>
                    <th>总金额</th>
                    <th>状态</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {foreach name="orders" item="order"}
                <tr>
                    <td>{$order.id}</td>
                    <td>{$order.order_sn}</td>
                    <td>{$order.user.username ?? '未知用户'}</td> <td>¥{$order.total_price}</td>
                    <td><?= $order->status == 'pending' ? '待支付' : '已完成' ?></td>
                    <td>{$order.create_time}</td>
                    <td class="action-links">
                        <a href="{:Url('admin/index/orderDetail', ['orderId' => $order.id])}">查看详情</a>
                        </td>
                </tr>
                {/foreach}
            </tbody>
        </table>
        <p class="back-link"><a href="{:Url('admin/index/index')}">返回后台首页</a></p>
    </div>
</body>
</html>